import numpy

from ..helpers import article
from ._helpers import E2r2Scheme

_citation = article(
    authors=["Ann Haegemans", "Robert Piessens"],
    title="Construction of Cubature Formulas of Degree Seven and Nine Symmetric Planar Regions Using Orthogonal Polynomials",
    journal="SIAM Journal on Numerical Analysis",
    volume="14",
    number="3",
    month="jun",
    year="1977",
    pages="492-508",
    url="https://www.jstor.org/stable/2156699",
)


def haegemans_piessens_a():
    points = numpy.array(
        [
            [+0.20170108815574554176e1, +0.66375761187215295779],
            [+0.20170108815574554176e1, -0.66375761187215295779],
            [-0.20170108815574554176e1, +0.66375761187215295779],
            [-0.20170108815574554176e1, -0.66375761187215295779],
            [+0.98476839890675530777, +0.12768861958214330981e1],
            [+0.98476839890675530777, -0.12768861958214330981e1],
            [-0.98476839890675530777, +0.12768861958214330981e1],
            [-0.98476839890675530777, -0.12768861958214330981e1],
            [+0.30613476457677457443e1, +0.46903453468277595970e1],
            [+0.30613476457677457443e1, -0.46903453468277595970e1],
            [-0.30613476457677457443e1, +0.46903453468277595970e1],
            [-0.30613476457677457443e1, -0.46903453468277595970e1],
            [+0.94537268957255005523, 0.0],
            [-0.94537268957255005523, 0.0],
            [0.0, +0.61173496731957836852],
            [0.0, -0.61173496731957836852],
            [0.0, +0.19591634146694451281e1],
            [0.0, -0.19591634146694451281e1],
        ]
    )
    weights = numpy.array(
        [
            0.17824409716904986674e-1,
            0.17824409716904986674e-1,
            0.17824409716904986674e-1,
            0.17824409716904986674e-1,
            0.10359061145455720786,
            0.10359061145455720786,
            0.10359061145455720786,
            0.10359061145455720786,
            0.29533849436023968652e-5,
            0.29533849436023968652e-5,
            0.29533849436023968652e-5,
            0.29533849436023968652e-5,
            0.49164052937290833903,
            0.49164052937290833903,
            0.80202561214816026055,
            0.80202561214816026055,
            0.34294236161016425803e-1,
            0.34294236161016425803e-1,
        ]
    )
    return E2r2Scheme("Haegemans-Piessens a", weights, points, 9, _citation)


def haegemans_piessens_b():
    points = numpy.array(
        [
            [+0.96694705321448168544, +0.54814654501005997792],
            [+0.96694705321448168544, -0.54814654501005997792],
            [-0.96694705321448168544, +0.54814654501005997792],
            [-0.96694705321448168544, -0.54814654501005997792],
            [+0.19083049659109735246e1, +0.13197423644999266853e1],
            [+0.19083049659109735246e1, -0.13197423644999266853e1],
            [-0.19083049659109735246e1, +0.13197423644999266853e1],
            [-0.19083049659109735246e1, -0.13197423644999266853e1],
            [+0.78179791517036681132, +0.17802047946783606137e1],
            [+0.78179791517036681132, -0.17802047946783606137e1],
            [-0.78179791517036681132, +0.17802047946783606137e1],
            [-0.78179791517036681132, -0.17802047946783606137e1],
            [+0.20656927236857979092e1, 0.0],
            [-0.20656927236857979092e1, 0.0],
            [0.0, +0.10514665259055166337e1],
            [0.0, -0.10514665259055166337e1],
            [0.0, +0.27123443781396230497e1],
            [0.0, -0.27123443781396230497e1],
            [0.0, 0.0],
        ]
    )
    weights = numpy.array(
        [
            0.32177672377399565511,
            0.32177672377399565511,
            0.32177672377399565511,
            0.32177672377399565511,
            0.75565837988161898558e-2,
            0.75565837988161898558e-2,
            0.75565837988161898558e-2,
            0.75565837988161898558e-2,
            0.29955422056645523413e-1,
            0.29955422056645523413e-1,
            0.29955422056645523413e-1,
            0.29955422056645523413e-1,
            0.21567360952593067635e-1,
            0.21567360952593067635e-1,
            0.33171694733245710776,
            0.33171694733245710776,
            0.12375970377531042078e-2,
            0.12375970377531042078e-2,
            0.99539392442635720576,
        ]
    )
    return E2r2Scheme("Haegemans-Piessens b", weights, points, 9, _citation)
